**** This file replicates the results in the Table 2 of the paper as well as Figures 1-5, which are based upon the results in that table
**** This file also contains replication materials for the tables in the online appendix

****** Enter Directory Location Where Replication Data is Located
local dir "C:\Dropbox\Sync folders\Synchronization Files\Research\Humanitarian intervention\Data\Replication\"


use "`dir'greig replication data.dta", clear

log using "`dir'replication results.smcl", replace

**** Table 2 Models
heckprob Dyadterm c.lnhuman_aid lnnonhuman_aid ethnic secessionist c.med_efforts c.lnhuman_aid#c.med_efforts duration ongoing_conflicts Intensity peacekeeping, sel(med_ongoing=lnhuman_aid lnnonhuman_aid ethnic secessionist former_colony duration lag_medongoing lag_medongoing_count rebel_stronger rebel_parity ongoing_conflicts Intensity) cluster(dyad_id)

heckprob peace_cease c.lnhuman_aid lnnonhuman_aid ethnic secessionist c.med_efforts c.lnhuman_aid#c.med_efforts duration ongoing_conflicts Intensity peacekeeping, sel(med_ongoing=lnhuman_aid lnnonhuman_aid ethnic secessionist former_colony duration lag_medongoing lag_medongoing_count rebel_stronger rebel_parity ongoing_conflicts Intensity) cluster(dyad_id)

heckprob Dyadterm c.lnhuman_aid lnnonhuman_aid c.major_efforts#c.lnhuman_aid c.io_efforts#c.lnhuman_aid c.major_efforts#c.io_efforts ethnic secessionist med_efforts c.io_efforts c.major_efforts duration ongoing_conflicts Intensity peacekeeping, sel(med_ongoing=lnhuman_aid lnnonhuman_aid ethnic secessionist former_colony duration lag_medongoing lag_medongoing_count rebel_stronger rebel_parity ongoing_conflicts Intensity) cluster(dyad_id)

heckprob peace_cease c.lnhuman_aid lnnonhuman_aid c.major_efforts#c.lnhuman_aid c.io_efforts#c.lnhuman_aid c.major_efforts#c.io_efforts ethnic secessionist med_efforts c.io_efforts c.major_efforts duration ongoing_conflicts Intensity peacekeeping, sel(med_ongoing=lnhuman_aid lnnonhuman_aid ethnic secessionist former_colony duration lag_medongoing lag_medongoing_count rebel_stronger rebel_parity ongoing_conflicts Intensity) cluster(dyad_id)


***** Figure 1 - Varying aid by level of mediation
heckprob Dyadterm c.lnhuman_aid lnnonhuman_aid ethnic secessionist c.med_efforts c.lnhuman_aid#c.med_efforts duration ongoing_conflicts Intensity peacekeeping, sel(med_ongoing=lnhuman_aid lnnonhuman_aid ethnic secessionist former_colony duration lag_medongoing lag_medongoing_count rebel_stronger rebel_parity ongoing_conflicts Intensity) cluster(dyad_id)

margins, atmeans at(c.lnhuman_aid=(0(2)20) c.med_efforts=1 ethnic=0 secessionist=0 Intensity=1 peacekeeping=0) level(90) predict(pcond) saving(m_1, replace) noatlegend
marginsplot, recast(line) recastci(rline) ciopts(lpattern(dash)) title(Mediation efforts=1) ytitle(Predicted probability)
gr save med1.gph,replace

margins, atmeans at(c.lnhuman_aid=(0(2)20) c.med_efforts=2 ethnic=0 secessionist=0 Intensity=1 peacekeeping=0) level(90) predict(pcond) saving(m_2, replace) noatlegend
marginsplot, recast(line) recastci(rline) ciopts(lpattern(dash)) title(Mediation efforts=2) ytitle(Predicted probability)
gr save med2.gph,replace


margins, atmeans at(c.lnhuman_aid=(0(2)20) c.med_efforts=3 ethnic=0 secessionist=0 Intensity=1 peacekeeping=0) level(90) predict(pcond) saving(m_3, replace) noatlegend
marginsplot, recast(line) recastci(rline) ciopts(lpattern(dash)) title(Mediation efforts=3) ytitle(Predicted probability)
gr save med3.gph,replace

margins, atmeans at(c.lnhuman_aid=(0(2)20) c.med_efforts=4 ethnic=0 secessionist=0 Intensity=1 peacekeeping=0) level(90) predict(pcond) saving(m_4, replace) noatlegend
marginsplot, recast(line) recastci(rline) ciopts(lpattern(dash)) title(Mediation efforts=4) ytitle(Predicted probability)
gr save med4.gph,replace

gr combine med1.gph med2.gph med3.gph med4.gph, cols(2) rows(2) ycommon 
graph save Graph "`dir'Figure 1 replication.gph", replace


***** Figure 2 - High aid, varying mediation
margins, atmeans at(c.lnhuman_aid=20 c.med_efforts=(1(1)8) ethnic=0 secessionist=0 Intensity=2) level(90) predict(pcond) saving(m_1, replace) noatlegend
marginsplot, recast(line) recastci(rline) ciopts(lpattern(dash)) title("") ytitle(Predicted probability)
graph save Graph "`dir'Figure 2 replication.gph", replace


***** Figure 3 - Peace - Varying aid by level of mediation
heckprob peace_cease c.lnhuman_aid lnnonhuman_aid ethnic secessionist c.med_efforts c.lnhuman_aid#c.med_efforts duration ongoing_conflicts Intensity peacekeeping, sel(med_ongoing=lnhuman_aid lnnonhuman_aid ethnic secessionist former_colony duration lag_medongoing lag_medongoing_count rebel_stronger rebel_parity ongoing_conflicts Intensity) cluster(dyad_id)

margins, atmeans at(c.lnhuman_aid=(0(2)20) c.med_efforts=1 ethnic=0 secessionist=0 Intensity=1 peacekeeping=0) level(90) predict(pcond) saving(m_1, replace) noatlegend
marginsplot, recast(line) recastci(rline) ciopts(lpattern(dash)) title(Mediation efforts=1) ytitle(Predicted probability)
gr save cease1.gph,replace

margins, atmeans at(c.lnhuman_aid=(0(2)20) c.med_efforts=2 ethnic=0 secessionist=0 Intensity=1 peacekeeping=0) level(90) predict(pcond) saving(m_2, replace) noatlegend
marginsplot, recast(line) recastci(rline) ciopts(lpattern(dash)) title(Mediation efforts=2) ytitle(Predicted probability)
gr save cease2.gph,replace

margins, atmeans at(c.lnhuman_aid=(0(2)20) c.med_efforts=3 ethnic=0 secessionist=0 Intensity=1 peacekeeping=0) level(90) predict(pcond) saving(m_3, replace) noatlegend
marginsplot, recast(line) recastci(rline) ciopts(lpattern(dash)) title(Mediation efforts=3) ytitle(Predicted probability)
gr save cease3.gph,replace

margins, atmeans at(c.lnhuman_aid=(0(2)20) c.med_efforts=4 ethnic=0 secessionist=0 Intensity=1 peacekeeping=0) level(90) predict(pcond) saving(m_4, replace) noatlegend
marginsplot, recast(line) recastci(rline) ciopts(lpattern(dash)) title(Mediation efforts=4) ytitle(Predicted probability)
gr save cease4.gph,replace

gr combine cease1.gph cease2.gph cease3.gph cease4.gph, cols(2) rows(2) ycommon 
graph save Graph "`dir'Figure 3 replication.gph", replace


***** Figure 4 - IO - Varying aid by level of mediation
heckprob Dyadterm c.lnhuman_aid lnnonhuman_aid c.major_efforts#c.lnhuman_aid c.io_efforts#c.lnhuman_aid c.major_efforts#c.io_efforts ethnic secessionist med_efforts c.io_efforts c.major_efforts duration ongoing_conflicts Intensity peacekeeping, sel(med_ongoing=lnhuman_aid lnnonhuman_aid ethnic secessionist former_colony duration lag_medongoing lag_medongoing_count rebel_stronger rebel_parity ongoing_conflicts Intensity) cluster(dyad_id)

margins, atmeans at(c.lnhuman_aid=(0(2)20) med_efforts=1 io_efforts=1 major_efforts=0 ethnic=0 secessionist=0 Intensity=1 peacekeeping=0) level(90) predict(pcond) saving(m_1, replace) noatlegend
marginsplot, recast(line) recastci(rline) ciopts(lpattern(dash)) title(IO mediation=1) ytitle(Predicted probability)
gr save io1.gph,replace

margins, atmeans at(c.lnhuman_aid=(0(2)20) med_efforts=2 io_efforts=2 major_efforts=0 ethnic=0 secessionist=0 Intensity=1 peacekeeping=0) level(90) predict(pcond) saving(m_2, replace) noatlegend
marginsplot, recast(line) recastci(rline) ciopts(lpattern(dash)) title(IO mediation=2) ytitle(Predicted probability)
gr save io2.gph,replace

margins, atmeans at(c.lnhuman_aid=(0(2)20) med_efforts=3 io_efforts=3 major_efforts=0 ethnic=0 secessionist=0 Intensity=1 peacekeeping=0) level(90) predict(pcond) saving(m_3, replace) noatlegend 
marginsplot, recast(line) recastci(rline) ciopts(lpattern(dash)) title(IO mediation=3) ytitle(Predicted probability)
gr save io3.gph,replace

margins, atmeans at(c.lnhuman_aid=(0(2)20) med_efforts=4 io_efforts=4 major_efforts=0 ethnic=0 secessionist=0 Intensity=1 peacekeeping=0) level(90) predict(pcond) saving(m_4, replace) noatlegend 
marginsplot, recast(line) recastci(rline) ciopts(lpattern(dash)) title(IO mediation=4) ytitle(Predicted probability)
gr save io4.gph,replace

gr combine io1.gph io2.gph io3.gph io4.gph, cols(2) rows(2) ycommon 
graph save Graph "`dir'Figure 4 replication.gph", replace


***** Figure 5 - Major power - Varying aid by level of mediation
gr combine maj1.gph maj2.gph maj3.gph maj4.gph, cols(2) rows(2) ycommon 
graph save Graph "`dir'Figure 5 replication.gph", replace


*****
***** Appendix Analyses
*****
**** Appendix 2: Two Consecutive Non-Violent Years Required for Conflict Termination
use "`dir'greig replication data-2yr term.dta", clear

heckprob terminate2 c.lnhuman_aid lnnonhuman_aid ethnic secessionist c.med_efforts c.lnhuman_aid#c.med_efforts duration ongoing_conflicts Intensity peacekeeping, sel(med_ongoing=lnhuman_aid lnnonhuman_aid ethnic secessionist former_colony duration lag_medongoing lag_medongoing_count rebel_stronger rebel_parity ongoing_conflicts Intensity) cluster(dyad_id)

heckprob terminate2 c.lnhuman_aid lnnonhuman_aid c.major_efforts#c.lnhuman_aid c.io_efforts#c.lnhuman_aid c.major_efforts#c.io_efforts ethnic secessionist med_efforts c.io_efforts c.major_efforts duration ongoing_conflicts Intensity peacekeeping, sel(med_ongoing=lnhuman_aid lnnonhuman_aid ethnic secessionist former_colony duration lag_medongoing lag_medongoing_count rebel_stronger rebel_parity ongoing_conflicts Intensity) cluster(dyad_id)


**** Appendix 3: Three Consecutive Non-Violent Years Required for Conflict Termination
use "`dir'greig replication data-3yr term.dta", clear

heckprob terminate3 c.lnhuman_aid lnnonhuman_aid ethnic secessionist c.med_efforts c.lnhuman_aid#c.med_efforts duration ongoing_conflicts Intensity peacekeeping, sel(med_ongoing=lnhuman_aid lnnonhuman_aid ethnic secessionist former_colony duration lag_medongoing lag_medongoing_count rebel_stronger rebel_parity ongoing_conflicts Intensity) cluster(dyad_id)

heckprob terminate3 c.lnhuman_aid lnnonhuman_aid c.major_efforts#c.lnhuman_aid c.io_efforts#c.lnhuman_aid c.major_efforts#c.io_efforts ethnic secessionist med_efforts c.io_efforts c.major_efforts duration ongoing_conflicts Intensity peacekeeping, sel(med_ongoing=lnhuman_aid lnnonhuman_aid ethnic secessionist former_colony duration lag_medongoing lag_medongoing_count rebel_stronger rebel_parity ongoing_conflicts Intensity) cluster(dyad_id)

log close

translate "`dir'replication results.smcl" "`dir'replication results.ps", replace
